﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebApiClient.Attributes;
using WebApiClient.Contexts;
using WebApiClient;

namespace Rest.WebApiClient.Contracts
{

    /// <summary>
    /// 自定义过滤器
    /// </summary>

    class SignFilter : ApiActionFilterAttribute
    {
        public override Task OnBeginRequestAsync(ApiActionContext context)
        {
            var sign = DateTime.Now.Ticks.ToString();
            context.RequestMessage.AddUrlQuery("sign", sign);
            return base.OnBeginRequestAsync(context);
        }
    }

    class MyGlobalFilter : IApiActionFilter
    {
        public Task OnBeginRequestAsync(ApiActionContext context)
        {
            
            // do something
            return Task.CompletedTask;
        }

        public Task OnEndRequestAsync(ApiActionContext context)
        {
            // do something
            return Task.CompletedTask;
        }
    }
}
